package com.woniuxy.qiantai.consumer;

import com.rabbitmq.client.Channel;
import com.woniuxy.qiantai.config.SendSmsUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

@Component
public class resetPasswordConsumer {

    /**
     * 消费者异步发送重置密码的短信
     * @param map
     */
    @RabbitListener(queues = "resetPassword")
    public void msg(Map<String,String> map, Message message, Channel channel) throws IOException {
        SendSmsUtils.sendAccount(map.get("phoneNumber"),map.get("password"),1747984);
        //确认消费机制
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
